/*Count four students' scores of three courses.
 * Each students has three course.
 * Count the total and mean score.
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct student_st
{
    long num;
    char name[16];
    char gender[1];
    float scores[3];
    float total;
    float means;
}Stu;

void count(Stu *stu)
{
    float sum1 = 0.0,mean1 = 0.0;
    int i,n;
    n = sizeof stu->scores / sizeof stu->scores[0];
    for(i = 0; i < n; i++)
    {
        sum1 += stu->scores[i];
    }
    stu->total = sum1;
    stu->means = sum1 / n;
}

int main(int argc, char *argv[])
{
    enum {N = 4};
    Stu stu[N];
    int i;
    puts("Enter num,name ,gender:\n");
    for(i = 0; i < N; i++)
    {
        scanf("%ld%s%s%f%f%f",&stu[i].num,stu[i].name,stu[i].gender,&stu[i].scores[0],
            &stu[i].scores[1],&stu[i].scores[2]);
        count(&stu[i]);
    }
    
    
    
    for(i = 0; i < N; i++)
    {
        printf("%8ld%10s%6s%6.1f%6.1f%6.1f%6.1f%6.1f\n",stu[i].num,stu[i].name,stu[i].gender,
            stu[i].scores[0],stu[i].scores[1],stu[i].scores[2],stu[i].total,stu[i].means);
    }
    
    puts("Hello, World!");
    return 0;
}
